//
//  YBaseNavigationController.swift
//  TestAPIManager
//
//  Created by yq on 2020/10/19.
//  Copyright © 2020 杨庆. All rights reserved.
//

import UIKit

let kNavBackImage = UIImage(named: "nav_back")!

class YBaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationBar.titleTextAttributes = [.font:UIFont(name: "GTWalsheim-Bold", size: 14) as Any ]
    }
        
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            /* 判断网络是否可用*/
            // code -> 不可用 return
            viewController.hidesBottomBarWhenPushed = true
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(
                image: kNavBackImage,
                style: .plain,
                target: self,
                action: #selector(goBack)
            )
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    override var childForStatusBarStyle: UIViewController? {
        topViewController
    }
    
    @objc func goBack() {
        popViewController(animated: true)
    }

}
